package com.fowo.api.datainterface.service.serviceCore;

import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import com.fowo.api.datainterface.constants.DataTypeKind;
import com.fowo.api.datainterface.model.DataContextModel;
import com.fowo.api.datainterface.util.JScriptUtil;

/**
 * 数据接口 服务实现类
 */

public interface BaseInvokeService {

    DataTypeKind getType();


    Object getAuth(DataContextModel.DatainterfaceAuthorityModel invoke)  ;

    default Object invoke(DataContextModel.DatainterfaceInvokeModel invoke, Object currentParamsMap, JSONObject currentHeadersMap) {
        return SpringUtil.getBean(JScriptUtil.class).callJsInvoke(invoke.getDataProcessing(), currentParamsMap == null ? new JSONObject() : currentParamsMap, null, null);
    }
}
